package cn.amaake.magicplugin.nacos.util;

import java.util.Collections;
import java.util.Map;
import org.springframework.core.env.MapPropertySource;

public class NacosPropertySource extends MapPropertySource {
    private String groupId;
    private String dataId;
    private boolean autoRefreshed;
    private boolean first;
    private String before;
    private String after;
    private String type;
    private Map<Object, Object> properties;
    private Map<String, Object> attributesMetadata;
    private Object origin;
    private String beanName;
    private Class<?> beanType;

    public NacosPropertySource(String dataId, String groupId, String name, String nacosConfig, String type) {
        super(name, NacosUtils.toProperties(dataId, groupId, nacosConfig, type));
        this.type = type;
    }

    public String getGroupId() {
        return this.groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getDataId() {
        return this.dataId;
    }

    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    public boolean isAutoRefreshed() {
        return this.autoRefreshed;
    }

    public void setAutoRefreshed(boolean autoRefreshed) {
        this.autoRefreshed = autoRefreshed;
    }

    public boolean isFirst() {
        return this.first;
    }

    public void setFirst(boolean first) {
        this.first = first;
    }

    public String getBefore() {
        return this.before;
    }

    public void setBefore(String before) {
        this.before = before;
    }

    public String getAfter() {
        return this.after;
    }

    public void setAfter(String after) {
        this.after = after;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Map<Object, Object> getProperties() {
        return this.properties;
    }

    public void setProperties(Map<Object, Object> properties) {
        this.properties = properties;
    }

    public Map<String, Object> getAttributesMetadata() {
        return this.attributesMetadata != null ? this.attributesMetadata : Collections.emptyMap();
    }

    public void setAttributesMetadata(Map<String, Object> attributesMetadata) {
        this.attributesMetadata = attributesMetadata;
    }

    public Object getOrigin() {
        return this.origin;
    }

    public void setOrigin(Object origin) {
        this.origin = origin;
    }

    public String getBeanName() {
        return this.beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public Class<?> getBeanType() {
        return this.beanType;
    }

    public void setBeanType(Class<?> beanType) {
        this.beanType = beanType;
    }

    protected void copy(NacosPropertySource original) {
        this.groupId = original.groupId;
        this.dataId = original.dataId;
        this.autoRefreshed = original.autoRefreshed;
        this.first = original.first;
        this.before = original.before;
        this.after = original.after;
        this.type = original.type;
        this.properties = original.properties;
        this.attributesMetadata = original.attributesMetadata;
        this.origin = original.origin;
        this.beanName = original.beanName;
        this.beanType = original.beanType;
    }
}